<?php 

namespace pmvc\mvc;

class ModelUtil {

	/**
	 * Replaces occurences of model keys in string.  ie:
	 * <pre>
	 * $arr = Array("name"=>"brian", "age"=>31);
	 * </pre>
	 * applied to:
	 * <pre>{name} is {age} years old.</pre>
	 * becomes:
	 * <pre>brian is 31 years old.</pre>
	 * @param string $str
	 * @param Model $model
	 */
	public static function stringReplace($str, Model $model) {
		foreach ($model->getArrayCopy() as $key => $value) {
			$key = "{".$key."}";
			if (is_string($value) || is_numeric($value)) {
				$str = str_replace($key, $value, $str);
			}
		}
		return $str;
	}
	
	
}


?>